import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'
import tagsView from './modules/tagsView'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    app,
    settings,
    user,
    tagsView
  },
  getters,
  // vuex的插件，默认情况下会存所有的vuex里的数据
  plugins: [
    createPersistedState({
      key: 'hmhr97', // 修改默认的保存的key
      paths: ['user.token', 'user.tokenTime']
      // 默认存到localStorage，如果要改，用下面的代码
      // storage: sessionStorage
    })
  ]
})

export default store
